#include "vec4.h"

ostream& operator<<(ostream& oo, vec4 v)
{
	oo << '[' << v.real << ',' << v.Iim << ',' << v.Jim << ',' << v.Kim << ']';
	return oo;
}

vec4& vec4::operator+=(const vec4& a)
{
	this->Iim += a.Iim;
	this->Jim += a.Jim;
	this->Kim += a.Kim;
	this->real += a.real;
	return *this;
}

vec4& vec4::operator-=(const vec4& a)
{
	this->Iim -= a.Iim;
	this->Jim -= a.Jim;
	this->Kim -= a.Kim;
	this->real -= a.real;
	return *this;
}

vec4& vec4::operator*=(const vec4& a)
{
	this->Iim *= a.Iim;
	this->Jim *= a.Jim;
	this->Kim *= a.Kim;
	this->real *= a.real;
	return *this;
}

vec4& vec4::operator/=(const vec4& a)
{
	this->Iim /= a.Iim;
	this->Jim /= a.Jim;
	this->Kim /= a.Kim;
	this->real /= a.real;
	return *this;
}

vec4& vec4::operator+(double a)
{
	vec4 tmpV = { a,a,a,a };
	vec4 reV = tmpV + *this;
	return reV;
}

vec4& vec4::operator-(double a)
{
	vec4 tmpV = { a,a,a,a };
	vec4 reV = tmpV - *this;
	return reV;
}


vec4& vec4::operator*(double a)
{
	vec4 tmpV = { a,a,a,a };
	vec4 reV = tmpV * *this;
	return reV;
}

vec4& vec4::operator/(double a)
{
	vec4 tmpV = { a,a,a,a };
	vec4 reV = tmpV / *this;
	return reV;
}

vec4& vec4::operator+=(double d)
{
	vec4 a = { d,d,d,d };
	this->Iim += a.Iim;
	this->Jim += a.Jim;
	this->Kim += a.Kim;
	this->real += a.real;
	return *this;
}

vec4& vec4::operator-=(double d)
{
	vec4 a = { d,d,d,d };
	this->Iim -= a.Iim;
	this->Jim -= a.Jim;
	this->Kim -= a.Kim;
	this->real -= a.real;
	return *this;
}

vec4& vec4::operator*=(double d)
{
	vec4 a = { d,d,d,d };
	this->Iim *= a.Iim;
	this->Jim *= a.Jim;
	this->Kim *= a.Kim;
	this->real *= a.real;
	return *this;
}

vec4& vec4::operator/=(double d)
{
	vec4 a = { d,d,d,d };
	this->Iim /= a.Iim;
	this->Jim /= a.Jim;
	this->Kim /= a.Kim;
	this->real /= a.real;
	return *this;
}

double& vec4::operator[](int idx)
{
	switch (idx)
	{
	case 0:
		return real;
	case 1:
		return Iim;
	case 2:
		return Jim;
	case 3:
		return Kim;
	}
}

vec4& vec4::operator+(const vec4& a)
{
	vec4 reV = *this;
	reV.Iim += a.Iim;
	reV.Jim += a.Jim;
	reV.Kim += a.Kim;
	reV.real += a.real;
	return reV;
}

vec4& vec4::operator-(const vec4& a)
{
	vec4 reV = *this;
	reV.Iim -= a.Iim;
	reV.Jim -= a.Jim;
	reV.Kim -= a.Kim;
	reV.real -= a.real;
	return reV;
}

vec4& vec4::operator*(const vec4& a)
{
	vec4 reV = *this;
	reV.Iim *= a.Iim;
	reV.Jim *= a.Jim;
	reV.Kim *= a.Kim;
	reV.real *= a.real;
	return reV;
}

vec4& vec4::operator/(const vec4& a)
{
	vec4 reV = *this;
	reV.Iim /= a.Iim;
	reV.Jim /= a.Jim;
	reV.Kim /= a.Kim;
	reV.real /= a.real;
	return reV;
}
